<script setup>
import { ref, onMounted, defineProps,watch } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
//子父组件传输数据Props
const props = defineProps({
    //底边那4个
    type2: String,
    //中间得值
    num2:String
})

const title = ref('我的钱包')
const return1 = ref(false)

router.beforeEach(async (to, from) => {

    let newTit = props.num2
    
    if(sessionStorage.getItem('goto')!=null){   
        newTit = sessionStorage.getItem('goto')
        sessionStorage.removeItem('goto')
    }else{
        newTit = props.num2
    }

    if(to.fullPath=='/'||to.fullPath=='/card-all'||to.fullPath=='/ransaction-records'||to.fullPath=='/personal-settings'){
        return1.value = false
        title.value = props.type2
    }else if(to.fullPath=='/collection-payment'){
        return1.value = true
        title.value = '收付款'
    }else if(to.fullPath=='/recharge'){
        return1.value = true
        title.value = '充值'
    }else if(to.fullPath=='/withdrawal'){
        return1.value = true
        title.value = '提现'
    }else if(to.fullPath=='/select-merchant-payment'){
        return1.value = true
        title.value = '向商户付款'
    }else if(to.fullPath=='/scan-code-payment'){
        return1.value = true
        title.value = '扫码付款'
    }else if(to.fullPath=='/NFCpayment'){
        return1.value = true
        title.value = 'NFC支付'
    }else if(to.fullPath=='/wallet-transfer'){
        return1.value = true
        title.value = '钱包转账'
    }else if(to.fullPath=='/collection'){
        return1.value = true
        title.value = '收钱'
    }else if(to.fullPath=='/person-center'){
        return1.value = true
        title.value = '个人中心'
    }else if(to.fullPath=='/ransaction-records'){
        return1.value = true
        title.value = '交易记录'
    }else if(to.fullPath=='/payment-password'){
        return1.value = true
        title.value = '支付限额'
    }else if(to.fullPath=='/pay-password-setting'){
        return1.value = true
        title.value = '设置支付密码'
    }else if(to.fullPath=='/pay-last-password'){
        return1.value = true
        title.value = '设置支付密码'
    }else if(to.fullPath=='/card-info'){
        return1.value = true
        title.value = '我的银行卡'
    }else if(to.fullPath=='/card-info-credit'){
        return1.value = true
        title.value = '我的银行卡'
    }else{
        return1.value = true
        title.value = newTit
    }
})


</script>

<template>
    <div class="left">
        <i class="iconfont icon-jiantou-copy bottom-1" v-if="return1" @click="() => {
            router.go(-1);
        }"></i>
    </div>
    <div class="title">
        <p>{{ title }}</p>
    </div>
</template>

<style scoped>
.left {
    position: absolute;
}
</style>